package cac.fenjian.resource.wmsdeliverplan.dao;

import cac.fenjian.resource.WmsDeliverPlan.dto.WmsDeliverPlanDTO;
import cn.hutool.core.lang.hash.Hash;
import com.github.pagehelper.Page;
import org.apache.coyote.http2.Http2AsyncUpgradeHandler;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.PostMapping;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public interface WmsDeliverPlanDao {
    //分页查询扫码移交界面
    public Page<WmsDeliverPlanDTO> searchPlanByPage(@Param("bean") WmsDeliverPlanDTO wmsDeliverPlanDTO, @Param("orderBy") String orderBy, @Param("keyWords") String keyWords);

    //移交条件查询
    public Page<WmsDeliverPlanDTO> searchDeliverByParams(@Param("bean") WmsDeliverPlanDTO wmsDeliverPlanDTO, @Param("orderBy") String orderBy, @Param("startTime") Date startTime, @Param("endTime") Date endTime);

    //分页退回扫码移交界面
    public Page<WmsDeliverPlanDTO> searchRetrunByPage(@Param("bean") WmsDeliverPlanDTO wmsDeliverPlanDTO, @Param("orderBy") String orderBy, @Param("keyWords") String keyWords);

    //退回条件查询
    public Page<WmsDeliverPlanDTO> searchRetrunByParams(@Param("bean") WmsDeliverPlanDTO wmsDeliverPlanDTO, @Param("orderBy") String orderBy, @Param("startTime") Date startTime, @Param("endTime") Date endTime);

    //零件接收
    public Page<WmsDeliverPlanDTO> searchPlanByItemTypeAM(@Param("bean") WmsDeliverPlanDTO wmsDeliverPlanDTO, @Param("orderBy") String orderBy, @Param("keyWords") String keyWords,@Param("IP")String IP);

    /**
     * 移交数据改变状态
     * @param id
     * @return
     */
    public Integer changeTransferType(String id, Date date,String IP,String userCode);

    Integer changeTransferTypeBzj(String barcode, Date date,String IP,String userCode);
    /**
     * 根据合格证号修改物料移交状态
     * @param id
     * @param date
     * @return
     */
    public Integer changeTransferTypeByMesCheckId(String id, Date date,String IP,String userCode);


    /**
     * 退回数据改变状态
     * @param id
     * @return
     */
    public Integer changeReturnType(String wmsDeliverPlanId,String id,String returnReason,Date date,String userId,String userCode);

    //接收备注
    int updateDeliveryRemark(@Param("map") HashMap map,@Param("remark") String remark);
    //成品接收
    public Page<WmsDeliverPlanDTO> searchPlanByItemTypeFS(@Param("bean") WmsDeliverPlanDTO wmsDeliverPlanDTO, @Param("orderBy") String orderBy, @Param("keyWords") String keyWords);

    //标件接收
    public List<HashMap> searchPlanByItemTypeZ(@Param("requireShop") String requireShop);

    //yebo 物料入库界面未入库数据 0729
    List<HashMap> searchBeputMaterial(@Param("ip") String ip);

    //物料入库页面未入库数据
    public Page<WmsDeliverPlanDTO> searchPlanByIsReceive(@Param("bean") WmsDeliverPlanDTO wmsDeliverPlanDTO, @Param("orderBy") String orderBy, @Param("keyWords") String keyWords,@Param("ip") String ip);

    //物料入库页面已入库数据
    public Page<WmsDeliverPlanDTO> searchReceiveOready(@Param("bean") WmsDeliverPlanDTO wmsDeliverPlanDTO, @Param("orderBy") String orderBy, @Param("keyWords") String keyWords,@Param("ip") String ip);

    //零件退货页面数据
    public Page<WmsDeliverPlanDTO> searchPlanPartReject(@Param("bean") WmsDeliverPlanDTO wmsDeliverPlanDTO, @Param("orderBy") String orderBy, @Param("keyWords") String keyWords);

    //成品退货页面数据
    public Page<WmsDeliverPlanDTO> searchPlanFinProReject(@Param("bean") WmsDeliverPlanDTO wmsDeliverPlanDTO, @Param("orderBy") String orderBy, @Param("keyWords") String keyWords);

    //标准件退货页面数据
    public Page<WmsDeliverPlanDTO> searchPlanZReject(@Param("bean") WmsDeliverPlanDTO wmsDeliverPlanDTO, @Param("orderBy") String orderBy, @Param("keyWords") String keyWords);

    //标准件条件查询
    public Page<WmsDeliverPlanDTO> searchByZ(@Param("bean") WmsDeliverPlanDTO wmsDeliverPlanDTO, @Param("orderBy") String orderBy, @Param("keyWords") String keyWords, @Param("startTime") Date startTime, @Param("endTime") Date endTime, @Param("drawNo") String drawNo,@Param("funcType")String funcType);

    /*查询配送计划表中的数据*/
    public WmsDeliverPlanDTO searchDeliverPlan(String barcode);

    //根据物流编码查询数据
    public Integer searchByBarCode(@Param("barcode") String barcode);
    //查询标件是存在
    Integer searchBjExists(@Param("barcode") String barcode);
    //查询标准件物料条码
    List<String> queryBzjBarcode(@Param("barcode") String barcode);

    String queryDeliveryRemark(@Param("barcode") String barcode);

    //根据成品合格证号查询数据
    public Integer searchByMesCheckQualiticationId(@Param("barcode")String barcode);

    int searchDeliveryPlanExists(@Param("barcode") String barcode);

    //根据物流编码查询数据状态是否合规
    public Integer isLegalByBarCode(@Param("barcode") String barcode);

    //根据物料编码查询需入库的移交物料信息
    public List<HashMap> searchByItemCode(@Param("workbCode")String workbinCode,@Param("IP")String IP);

    //物料入库扫码时返回大件货物库位号
    public List<HashMap> searchLocatorNo();

    //查询拆分的相同合格证
    public List<String> selectBarcodesCp(@Param("qualification") String qualification);

    //根据操作数据，更新移交表数据
    public int updatePlanDto(@Param("bean")WmsDeliverPlanDTO wmsDeliverPlanDTO);

    //查询交接单中退库状态
    public String searchPlanRet(@Param("map") WmsDeliverPlanDTO map);

    //全部入库物料更改状态
    public int updateDeliveryStatus(@Param("bean")WmsDeliverPlanDTO wmsDeliverPlanDTO);

    //查询状态是否为6
    public int searchIsFinish(@Param("bean") WmsDeliverPlanDTO wmsDeliverPlanDTO);

    //删除预上账修改交接单
    public int updateDeleteAdvancePosting(@Param("map") HashMap map);

    //成品预上账
    public int insertAdvancePosting(@Param("map")HashMap map);
    //无库存交接修改预上账状态
    int updateNoInvAdvancePosting(@Param("map")HashMap map);
    //预上账时，修改备注
    int updateDeliveryRemarkOnPreConfirm(@Param("map") HashMap map);

    //标准件预上账
    public int insertPreConfirmBzj(@Param("map")HashMap map);

    //删除质量信息
    public int deleteQuality(@Param("map")HashMap map);
    //删除零件合格证
    public int deleteLjCertificate(@Param("map")HashMap map);
    //删除成品合格证
    public int deleteCpCertificate(@Param("map")HashMap map);


    //新增质量信息表数据
    public int insertWmsQualityInfo(@Param("map")HashMap map);
    //
    int updateWmsQualityXLimitLotNo(@Param("map") HashMap map);

    int updateWmsQualityInfo(@Param("map") HashMap map);

    //yebo 校验质量表是否存在
    int queryQualityIsExists(@Param("map")HashMap map);

    //101-ERP零件扫码移交
    public HashMap scanDeliveryLj(String  barcode);

    //101-ERP成品扫码移交
    public HashMap scanDeliveryCp(String  barcode);

    //查询无聊类型
    public String selectItemType(String barcode);

    //101-ERP 零件、成品扫码获取当前操作的交接单
    String getScanBarcodeWmsDeliverPlanId(String barcode);

    //标准件获取交接单id
    List<String> searchBzjWmsId(String barcode);

    //101-ERP 成品扫码退回
    public HashMap scanBackCp(@Param("wmsDeliverPlanId") String wmsDeliverPlanId,@Param("barcode") String barcode);
    //101-ERP 零件扫码退回
    public HashMap scanBackLj(@Param("wmsDeliverPlanId") String wmsDeliverPlanId,@Param("barcode") String barcode);

    //yebo 2023-04-06 查询扫码回退是否发起协调
    int searchCreateCoordinate(@Param("wmsDeliveryPlanId") String wmsDeliveryPlanId);
    int updateCoordinateToZero(@Param("wmsDeliveryPlanId") String wmsDeliveryPlanId,@Param("userId") String userId);
    int searchOperIsSame(@Param("wmsDeliveryPlanId") String wmsDeliveryPlanId,
                         @Param("userCode") String userCode);
    int searchOperIsSameByBarcode(@Param("barcode") String barcode,
                                  @Param("userCode") String userCode);

    String queryDeliveryType(@Param("wmsDeliveryPlanId") String wmsDeliveryPlanId);

    //更新物料箱详细信息表
    public int updateMsWorkbinReceDetail(@Param("workbincode")String workbincode,@Param("bean") WmsDeliverPlanDTO wmsDeliverPlanDTO);

    public int updateMsReceDetail(@Param("workbincode")String workbincode,@Param("bean") WmsDeliverPlanDTO wmsDeliverPlanDTO);

    //MES-101   移交场景 --交接单
    public int shopMaterialDelivery(@Param("map")HashMap map);
    //MES-101   移交场景 --matchInfo
    public int shopMaterialInfo(@Param("map")HashMap map);
    //现场移交后出库,查询占用id
    public List<HashMap> searchAllotmentId(@Param("map")HashMap map);
    int queryIsExistsOutTransaction(@Param("map")HashMap map);
    String queryWmsInvOutAllotmentId(@Param("map")HashMap map);
    //MES-101   现场驳回场景
    public int ShopReturnMaterial(@Param("map")HashMap map);
    //MES-101   现场接受场景
    public int ShopMaterialRece(@Param("map")HashMap map);
    //MES-101   无故障退库
    public int MaterialReturn(@Param("map")HashMap map);
    //MES-101   正常退库插入退库申请单
    public int MaterialReturnApply(@Param("map")HashMap map);
    //MES-101   故障退库
    public int MaterialGzReturn(@Param("map")HashMap map);
    //MES-101   故障退库插入退库申请单
    public int MaterialGzReturnApply(@Param("map")HashMap map);
    //MES-101   报废退库
    public int MaterialBfReturn(@Param("map")HashMap map);
    //MES-101   报废退库插入退库申请单
    public int MaterialBfReturnApply(@Param("map")HashMap map);
    //MES-101   四联单退库
    public int MaterialSldReturn(@Param("map")HashMap map);
    //MES-101   四联单退库插入退库申请单
    public int MaterialSldReturnApply(@Param("map")HashMap map);
    //新增MDS_Item表
    public int AddMdsItem(@Param("map")HashMap map);
    //查询当前mdsItemId是否存在
    public Integer searchDistinct(@Param("map")HashMap map);
    //二次配套场景
    public int SecondMatch(@Param("map")HashMap map);
    //退库更新match_info表
    public int MaterialReturnMatchInfo(@Param("map")HashMap map);
    //驳回更新match_info表
    public int MaterialRejectMatchInfo(@Param("map")HashMap map);
    //接收更新match_info表
    public int MaterialReceiveMatchInfo(@Param("map")HashMap map);
    //二次配套更新match_info表
    public int MaterialSecondMatchInfo(@Param("map")HashMap map);
    //二次配套单
    public int InsertSecondMatch(@Param("map")HashMap map);
    //MES-101 物料更改 修改
    public int SenceMaterialUpdate(@Param("map")HashMap map);
    //MES-101 物料更改 新增
    public int SenceMaterialInsert(@Param("map")HashMap map);
    //MES-101 物料更改 删除
    public int SenceMaterialDelete(@Param("map")HashMap map);
    //MES-101 MATCH_BILL更改表 新增
    public int SenceUpdateInsert(@Param("map")HashMap map);
    //查询func
    public String searchFuncByBarcode(String barcode);

    String searchRequireShopByBarcode(String barcode);

    List<HashMap> searchListByBarcode(String barcode);

    public String searchFuncById(String barcode);

    int queryDeliveryQtyFromWmsDelivery(@Param("bean") WmsDeliverPlanDTO wmsDeliverPlanDTO);

    HashMap searchDeliveryType(@Param("wmsDeliveryPlanId") String wmsDeliveryPlanId);
//
    //查询扫码人工人
    HashMap searchWorkerCode (@Param("usercode")String usercode);

    //ixaojian 设置默认备注
    HashMap setDefaultNotes(@Param("itemCode")String itemCode);

    //查询原始交接单id
    String searchDeliveryPlanId(String id);

    int dealRepeatWdp(@Param("map")HashMap map);

    int updateWmsDeliveryPlanRemark(@Param("map") HashMap map);

    int checkInstoreMaterialShop(@Param("wmsDeliveryPlanId") String wmsDeliveryPlanId,@Param("shop") String shop);
}
